package com.haizhi.mespush.controller;

import com.haizhi.mespush.bean.Person;
import com.haizhi.mespush.job.HostMesPushJob;
import com.haizhi.mespush.service.WorkService;
import com.haizhi.mespush.util.Res;
import com.haizhi.mespush.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: Lixiaofei
 * @date: 2020/6/14 21:19
 */
@RestController
public class PersonController {

    @Autowired
    WorkService workService;

    @RequestMapping("/addNewPerson")
    public Result toChangeOrder(Person person) {
        return Res.ok(workService.saveOrUpdate(person));
    }

    @RequestMapping("/editPersion")
    public Result editPersion(Person person) {
        return Res.ok(workService.updateById(person));
    }

    @RequestMapping("/deletePerson")
    public Result deletePerson(Person person) {
        return Res.ok(workService.removeById(person.getId()));
    }

    @PostMapping("/upload")
    public Result upload(MultipartFile file){
        return Res.ok(workService.upload(file));
    }

}
